package com.lifa.controller;

import com.lifa.dao.TaocanPeizhiDao;
import com.lifa.entity.Taocan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/taocanpeizhi")
@Scope("prototype")
public class TaocanPeizhiController {
    @Autowired
    private TaocanPeizhiDao taocanPeizhiDao;
    @RequestMapping("/tao")
    @ResponseBody
    public List<Taocan> list(){
        return taocanPeizhiDao.query();
    }

    @RequestMapping("/queryByName")
    @ResponseBody
    public Map<String,Object> queryPageByName(String name,int offset,int limit){
        Map<String,Object> map = new HashMap<>() ;
        map.put("rows",taocanPeizhiDao.queryPage(name,offset,limit)) ;
        map.put("total",taocanPeizhiDao.getTotalCount(name)) ;
        return  map ;
    }
}
